import router from './router'
import store from './store'
import { Message } from 'element-ui'
import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style
// get token from cookie
 
import common from '@/common/js/common'
import getPageTitle from '@/utils/get-page-title'
import loaclstore from 'store-gem.js'
var localstore = new loaclstore()

NProgress.configure({ showSpinner: false }) // NProgress Configuration


router.beforeEach(async(to, from, next) => {
  // start progress bar
 // NProgress.start()


  if (common.isStringEmpty(localstore.get("access_token"))) { 
    console.log("zzzzzz");
    if (to.path === '/login') {
      next();
    } else { 
      next('/login')
    }
   
    
  } else {
    if (to.path === '/login') {
      next('/');
    } else { 
      next();
    }
    
  }


})

router.afterEach(() => {
  // finish progress bar
  console.log("zzzzzzz2222");
  NProgress.done()
})
